<template>
	<section>
		<el-steps :active="step" align-center center style="width: 90%;margin:0 auto;margin-top: 50px;"  >
		  <el-step title="课程基本信息设置"></el-step>
		  <el-step title="课程内容选择"></el-step>
		  <el-step title="课程学习安排"></el-step>
		  <el-step title="课程权重设置"></el-step>
		</el-steps>		
		<el-row  :gutter="20">
			<el-col :span="20"  :offset="2" style="margin-top: 50px;">
				<div v-show="step==1">
					<el-form :model="addcourse" label-width="80px" :rules="addcourserule" ref="addcourse" >
					  <el-form-item label="课程名称" prop="name">
					    <el-input v-model="addcourse.name" placeholder="课程名称限制在15字以内"></el-input>
					  </el-form-item>	
					  <el-form-item label="课程简介"  label-width="80px">
					        <div class="edit_container">
					          <quill-editor
					          				v-model="addcourse.intro"
					                        ref="myQuillEditor"
					                        class="editer"
					                       >
					          </quill-editor>
					        </div>
					  </el-form-item>	
					  <el-form-item label="上课组数" prop="teamCount">
					    <el-select v-model="addcourse.teamCount" placeholder="上课组数">
					      <el-option label="1" value="1"></el-option>
					      <el-option label="2" value="2"></el-option>
					      <el-option label="3" value="3"></el-option>
					      <el-option label="4" value="4"></el-option>
					      <el-option label="5" value="5"></el-option>
					      <el-option label="6" value="6"></el-option>
					    </el-select>
					  </el-form-item>
					  <el-form-item label="上课人数" prop="personCount">
					    <el-select v-model="addcourse.personCount" placeholder="上课人数">
					      <el-option label="6" value="6"></el-option>
					      <el-option label="12" value="12"></el-option>
					      <el-option label="18" value="18"></el-option>
					      <el-option label="24" value="24"></el-option>
					      <el-option label="30" value="30"></el-option>
					    </el-select>
					  </el-form-item>
					  <el-form-item label="课程开始时间"  label-width="120px" prop="startTime" >
						    <el-date-picker 
						      v-model="addcourse.startTime"
						      type="datetime"
						      placeholder="选择日期时间">
						    </el-date-picker>	
					   </el-form-item>
					</el-form>	

				</div>
				<div v-show="step==2">
					<template>
						<div class="box-content">													
							<h1 style="margin:0">创业基础模块</h1>
							<el-button type="success" style="margin: 10px 0;" @click="addtemplebox(0,'basis')">添加创业基础课程章节</el-button>
							<el-table :data="basis"  height="200"  style="width: 100%"> 
								<el-table-column  type="index" width='80'>
								</el-table-column>						 	
							 	<el-table-column
							      prop="name"
							      label="课程章节名称"
							      >
							    </el-table-column>
							    <el-table-column prop="roughTime" label="建议学时（小时）" >
							    </el-table-column>
								<el-table-column label="操作">
									<template scope="scope">
										<el-button size="small" @click="deletelist('basis',scope.$index)" type="danger">删除</el-button>
										<el-button size="small" @click="getone(scope.row,scope.$index,'basis')" type="primary">设置</el-button>
										<el-button size="small" type="info" @click="Lookone(scope.row)">预览</el-button>
										<el-button size="small" @click="upRecord(basis,scope.$index)" type="success">上移</el-button>
										<el-button size="small" @click="downRecord(basis,scope.$index)" type="warning">下移</el-button>
									</template>					
								</el-table-column>
							</el-table>		
						</div>
					</template>
					<template>
						<div class="box-content">													
							<h1 style="margin:0">案例分析模块</h1>
							<el-button type="info" style="margin: 10px 0;"  @click="addtemplebox(1,'case')">添加案例分析课程章节</el-button>
							<el-table :data="casebox"  height="200"  style="width: 100%"> 
								<el-table-column  type="index" width='80'>
								</el-table-column>						 	
							 	<el-table-column
							      prop="name"
							      label="课程章节名称"
							      >
							    </el-table-column>
							    <el-table-column
							      prop="roughTime"
							      label="建议学时（小时）"
							     >
							    </el-table-column>
								<el-table-column label="操作">
									<template scope="scope">
										<el-button size="small" @click="deletelist('case',scope.$index)" type="danger">删除</el-button>
										<el-button size="small"  @click="getone(scope.row,scope.$index,'case')" type="primary">设置</el-button>
										<el-button size="small" type="info" @click="Lookone(scope.row)">预览</el-button>										
										<el-button size="small" @click="upRecord(casebox,scope.$index)" type="success">上移</el-button>
										<el-button size="small" @click="downRecord(casebox,scope.$index)" type="warning">下移</el-button>
									</template>					
								</el-table-column>
							</el-table>	
						</div>
					</template>	
					<template>
						<div class="box-content">													
							<h1 style="margin:0">沙盘推演模块</h1>
							<el-button type="warning" style="margin: 10px 0;" @click.native="drawFormVisible = true">添加沙盘推演课程章节</el-button>
							<el-table :data="derive"  height="200"  style="width: 100%"> 
								<el-table-column  type="index" width='80'>
								</el-table-column>						 	
							 	<el-table-column
							      prop="name"
							      label="沙盘推演图纸名称"
							      >
							    </el-table-column>
							    <el-table-column
							      prop="roughTime"
							      label="沙盘推演小节总建议学时（小时）"
							     >
							    </el-table-column>
								<el-table-column label="操作">
									<template scope="scope">
										<el-button size="small" @click="deletelist('draw',scope.$index)" type="danger">删除</el-button>
										<el-button size="small" @click="upRecord(derive,scope.$index)" type="success">上移</el-button>
										<el-button size="small" @click="downRecord(derive,scope.$index)" type="warning">下移</el-button>
									</template>					
								</el-table-column>
							</el-table>	
						</div>
					</template>		
					<template>
						<div class="box-content">													
							<h1 style="margin:0;margin-bottom: 10px;">项目路演模块</h1>
							<el-table :data="roads"  height="auto"  style="width: 100%"> 
								<el-table-column  type="index" width='80'>
								</el-table-column>						 	
							 	<el-table-column
							      prop="name"
							      label="项目路演模块"
							      >
							    </el-table-column>
							    <el-table-column
							    	 prop="roughTime"
							      label="项目路演小节总建议学时（小时）"
							     >					     
							    </el-table-column>	
								<el-table-column label="操作">
									<template scope="scope">
										<el-button size="small"  @click.native="RoadFormVisible = true" type="primary">设置</el-button>
									</template>					
								</el-table-column>							    
							</el-table>	
						</div>
					</template>						
				</div>	
				<div v-show="step==3">
					<el-col :span="24" class="card-margin">
						<el-card class="box-card">
						  <div slot="header" class="clearfix">
						    <span style="line-height: 36px;">创业基础课程板块</span>	
						     <el-button style="float: right;"@click="paiIndex(0)" type="primary" v-if="stageJson[0].startTime==''">排课</el-button>
						     <el-button style="float: right;"@click="paiIndex(0)" type="danger" v-if="stageJson[0].startTime!=''">重新排课</el-button>
						     
						  </div>
						  <el-col :span="24" class="text-box">
							<template>
							  <el-table
							    :data="basis"
							    style="width: 100%"
							   >
							    <el-table-column
							      prop="name"
							      label="课程章节名称"
							      width="200">
							    </el-table-column>
							    <el-table-column label="上课方式" >
							    	<template scope="scope">
							    		<p>{{stageJson[0].isOffline==0?'线上学习':"线下学习"}}</p>
							    	</template>
							    </el-table-column>
							    <el-table-column label="上课地点" >
							    	<template scope="scope">
							    		<p>{{stageJson[0].location}}</p>
							    	</template>							    	
							    </el-table-column>
							    <el-table-column label="开始时间" >
							    	<template scope="scope">
							    		<p>{{stageJson[0].startTime}}</p>
							    	</template>							    	
							    </el-table-column>								    
							    <el-table-column
							      prop="roughTime"
							      label="学时"
							      >
							    </el-table-column>							    
							  </el-table>
							</template>
						  </el-col>
						</el-card>						
					</el-col>
					<el-col :span="24"  class="card-margin">
						<el-card class="box-card">
						  <div slot="header" class="clearfix">
						    <span style="line-height: 36px;">案例分析课程板块</span>	
						     <el-button style="float: right;"  @click="paiIndex(1)" v-if="stageJson[1].startTime==''" type="primary">排课</el-button>
						      <el-button style="float: right;" @click="paiIndex(1)" type="danger" v-if="stageJson[1].startTime!=''">重新排课</el-button>
						  </div>
						  <el-col :span="24" class="text-box">
							<template>
							  <el-table
							    :data="casebox"
							    style="width: 100%"
							   >
							    <el-table-column
							      prop="name"
							      label="课程章节名称"
							      width="200">
							    </el-table-column>
							    <el-table-column label="上课方式" >
							    	<template scope="scope">
							    		<p>{{stageJson[1].isOffline==0?'线上学习':"线下学习"}}</p>
							    	</template>
							    </el-table-column>
							    <el-table-column label="上课地点" >
							    	<template scope="scope">
							    		<p>{{stageJson[1].location}}</p>
							    	</template>							    	
							    </el-table-column>
							    <el-table-column label="开始时间" >
							    	<template scope="scope">
							    		<p>{{stageJson[1].startTime}}</p>
							    	</template>							    	
							    </el-table-column>								    
							    <el-table-column
							      prop="roughTime"
							      label="学时"
							      >
							    </el-table-column>							    
							  </el-table>
							</template>
						  </el-col>
						</el-card>						
					</el-col>
					<el-col :span="24"  class="card-margin">
						<el-card class="box-card">
						  <div slot="header" class="clearfix">
						    <span style="line-height: 36px;">沙盘推演模块</span>	
						     <el-button style="float: right;" @click="paiIndex(2)" v-if="stageJson[2].startTime==''" type="primary">排课</el-button>
						     <el-button style="float: right;"@click="paiIndex(2)" type="danger" v-if="stageJson[2].startTime!=''">重新排课</el-button>
						  </div>
						  <el-col :span="24" class="text-box">
							<template>
							  <el-table
							    :data="derive"
							    style="width: 100%"
							   >
							    <el-table-column
							      prop="name"
							      label="课程章节名称"
							      width="200">
							    </el-table-column>
							    <el-table-column label="上课方式" >
							    	<template scope="scope">
							    		<p>{{stageJson[2].isOffline==0?'线上学习':"线下学习"}}</p>
							    	</template>
							    </el-table-column>
							    <el-table-column label="上课地点" >
							    	<template scope="scope">
							    		<p>{{stageJson[2].location}}</p>
							    	</template>							    	
							    </el-table-column>
							    <el-table-column label="开始时间" >
							    	<template scope="scope">
							    		<p>{{stageJson[2].startTime}}</p>
							    	</template>							    	
							    </el-table-column>									    
							    <el-table-column
							      prop="roughTime"
							      label="学时"
							      >
							    </el-table-column>							    
							  </el-table>
							</template>
						  </el-col>
						</el-card>						
					</el-col>
					<el-col :span="24"  class="card-margin">
						<el-card class="box-card">
						  <div slot="header" class="clearfix">
						    <span style="line-height: 36px;">项目路演板块</span>	
						     <el-button style="float: right;" @click="paiIndex(3)" v-if="stageJson[3].startTime==''" type="primary">排课</el-button>
						     <el-button style="float: right;"@click="paiIndex(3)" type="danger" v-if="stageJson[3].startTime!=''">重新排课</el-button>
						  </div>
						  <el-col :span="24" class="text-box">
							<template>
							  <el-table
							    :data="roads"
							    style="width: 100%"
							   >
							    <el-table-column
							      prop="name"
							      label="课程章节名称"
							      width="200">
							    </el-table-column>
							    <el-table-column label="上课方式" >
							    	<template scope="scope">
							    		<p>{{stageJson[3].isOffline==0?'线上学习':"线下学习"}}</p>
							    	</template>
							    </el-table-column>
							    <el-table-column label="上课地点" >
							    	<template scope="scope">
							    		<p>{{stageJson[3].location}}</p>
							    	</template>							    	
							    </el-table-column>
							    <el-table-column label="开始时间" >
							    	<template scope="scope">
							    		<p>{{stageJson[3].startTime}}</p>
							    	</template>							    	
							    </el-table-column>							    
							    <el-table-column
							      prop="roughTime"
							      label="学时"
							      >
							    </el-table-column>							    
							  </el-table>
							</template>
						  </el-col>
						</el-card>						
					</el-col>					
				</div>
				<div v-show="step==4">
					<el-form ref="quanzhong" :model="quanzhong" label-width="80px" :rules="quanzhongrules">
					  <el-form-item label="课程成绩构成" label-width="150px" >
					    <div style="width: 50%;text-align: center;">权重%</div>
					  </el-form-item>		
					  <el-form-item label="个人作业"  label-width="150px" prop="personWeight">
					    <el-input style="width: 50%;" type="number" placeholder="请输入个人作业权重" v-model='quanzhong.personWeight'></el-input>
					  </el-form-item>	
					  <el-form-item label="小组作业" label-width="150px" prop="teamWeight">
					    <el-input style="width: 50%;" type="number" placeholder="请输入小组作业权重"v-model='quanzhong.teamWeight'></el-input>
					  </el-form-item>	
					  <el-form-item label="课程进度"  label-width="150px" prop="completionWeight">
					    <el-input placeholder="请输入课程进度权重" type="number" style="width: 50%;" v-model='quanzhong.completionWeight'></el-input>
					  </el-form-item>	
					  <el-form-item label="课堂表现" label-width="150px" prop="performanceWeight">
					    <el-input placeholder="请输入课堂表现权重" type="number" style="width: 50%;" v-model='quanzhong.performanceWeight'></el-input>
					  </el-form-item>						  
					</el-form>						
				</div>
			</el-col>
		  <el-col :span="12" :offset="10" style="margin-top: 50px;">	
			<el-button @click="stepprive">上一步</el-button>			  	
		  	<el-button type="primary" @click="stepnext">下一步</el-button>
<!--			<el-button @click="OpenIsfree" type="success" v-if="step==4">创建课程</el-button>
-->		  </el-col>			
		</el-row>
		<!--新增界面-->
		<el-dialog  title="选择课程章节" :fullscreen="false" custom-class="workdialog" width="30%"  v-model="addFormVisible" :close-on-click-modal="false">
			<el-col :span="24" class="toolbar"  style="padding-bottom: 0px;">
				<el-form :inline="true">
					<el-form-item label="所属商业模式版块" v-if="courseType=='basis'">
					    <el-select placeholder="请选择版块" size="small"  v-model="templetbusinessModelId">
					    	<el-option value="" label="全部"></el-option>
					      <el-option v-for="el in bussinessList" :value="el.businessModelId" :label="el.name"></el-option>
					    </el-select>
					</el-form-item>		
					<el-form-item label="课程章节分类">
					    <el-select placeholder="请选择分类" size="small"  v-model="templet.templettype">
					      <el-option value="1" label="只看自己"></el-option>
					      <el-option value="2" label="共享小节"></el-option>
					      <el-option value="3" label="内置小节"></el-option>
					    </el-select>
					</el-form-item>						
					<el-form-item>
						<el-input  size="small"  v-model="templet.key" placeholder="输入查询的关键字"></el-input>
					</el-form-item>
					<el-form-item>
						<el-button type="primary"  size="small"  @click="getList">查询</el-button>
					</el-form-item>
				</el-form>
			</el-col>	
			<el-table :data="Lists" highlight-current-row  style="width: 100%;"  @selection-change="handleSelectionChange">
			    <el-table-column
			      type="selection"
			      width="55">	
			    </el-table-column>
				<el-table-column prop="name" label="课程章节名称"  >
				</el-table-column>
				<el-table-column prop="realName" label="创建人"  >
				</el-table-column>
				<el-table-column prop="orgName" label="所属单位" >
				</el-table-column>			
				<el-table-column prop="updateTime" label="添加时间" sortable>
				</el-table-column>
				<el-table-column prop="referenceCount" label="引用次数" sortable>
				</el-table-column>			
			</el-table>	
			<el-col :span="24" class="toolbar">
				<el-pagination layout="prev,pager,next" @current-change="handleCurrentChange" :page-size="5" :total="templet.total" style="float:right;">
				</el-pagination>
			</el-col>				
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="addFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="addList()" >添加</el-button>
			</div>
		</el-dialog>	
		<!--新增界面-->
		<el-dialog  title="选择沙盘推演图纸" :fullscreen="false" custom-class="workdialog" width="30%"  v-model="drawFormVisible" :close-on-click-modal="false">
			<el-table :data="drawlit" highlight-current-row  ref="multipleTable"  style="width: 100%;"  @selection-change="drawSelectionChange">
			    <el-table-column
			      type="selection"
			      width="100">	
			    </el-table-column>
				<el-table-column prop="name" label="沙盘推演图纸名称"  >
				</el-table-column>
			</el-table>				
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="drawFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="addraw()">添加</el-button>
			</div>
		</el-dialog>
		<!--设置界面-->
		<el-dialog  title="设置课程章节" :fullscreen="false" custom-class="templetdialog" width="30%"  v-model="editFormVisible" :close-on-click-modal="false">
			<el-form :model="edittemplet" status-icon class="demo-ruleForm"  :rules="edittempletrule" ref="edittemplet" label-width="50px">		
				<el-form-item label="课程章节名称"  label-width="80" > 
				    <el-input style="width:40%;" type="text"  placeholder="填写小节名称（15字以内）"  v-model="edittemplet.name"></el-input>
				</el-form-item>	
				<el-form-item label="课程章节类型" label-width="80" >
					{{edittemplet.courseStage==0?'创业基础课程章节':'案例分析课程章节'}}
				    </el-radio-group>
				</el-form-item>	
				<el-form-item label="所属商业模式版块" label-width="80"  v-if="edittemplet.courseStage==0">
				    <el-select placeholder="请选择版块"  v-model="edittemplet.businessModelId" disabled>
				      <el-option v-for="el in bussinessList" :value="el.businessModelId" :label="el.name"></el-option>
				    </el-select>
				</el-form-item>				
				<el-form-item label="教案选择"  label-width="80" >
					<el-row>
						<el-col :span="10">
						    <el-select placeholder="请选择教案选择" style="width: 100%;" v-model="edittemplet.planIds" multiple >
						      <el-option v-for="el in planlist"  :key="el.planId" :value="el.planId" :label="el.name"></el-option>
						    </el-select>							
						</el-col>
						<el-col :span="8" :offset="2">
						  <el-radio-group v-model="planselect">
						    <el-radio-button label="1">只看自己</el-radio-button>
						    <el-radio-button label="2">共享教案</el-radio-button>
						    <el-radio-button label="3">内置教案</el-radio-button>
						  </el-radio-group>							
						</el-col>						
					</el-row>

				</el-form-item>				
				<el-form-item label="视频选择" label-width="80">
					<el-row>
						<el-col :span="10">
						    <el-select placeholder="请选择视频选择" style="width: 100%;" v-model="edittemplet.videoIds" multiple >
						      <el-option v-for="el in videolist" :key="el.videoId" :value="el.videoId" :label="el.name"></el-option>
						    </el-select>							
						</el-col>
						<el-col :span="8" :offset="2">
							<el-radio-group v-model="videoselect">
							    <el-radio-button label="1">只看自己</el-radio-button>
							    <el-radio-button label="2">共享视频</el-radio-button>
							    <el-radio-button label="3">内置视频</el-radio-button>
							</el-radio-group>							
						</el-col>							
					</el-row>
				</el-form-item>		
				<el-form-item label="图纸选择" label-width="80" v-if="edittemplet.courseStage==1">
					<el-row>
						<el-col :span="10">
						    <el-select placeholder="请选择教案选择" style="width: 100%;" v-model="edittemplet.drawingIds" multiple >
						      <el-option v-for="el in drawlist" :key="el.drawingId"  :value="el.drawingId" :label="el.name"></el-option>
						    </el-select>							
						</el-col>
						<el-col :span="8" :offset="2">
							<el-radio-group v-model="drawselect">
							    <el-radio-button label="1">只看自己</el-radio-button>
							    <el-radio-button label="2">共享图纸</el-radio-button>
							    <el-radio-button label="3">内置图纸</el-radio-button>
							</el-radio-group>							
						</el-col>							
					</el-row>
				</el-form-item>		
				<el-form-item label="作业选择" label-width="80">
					<el-row>
						<el-col  :span="10">
						    <el-select placeholder="请选择作业选择" style="width: 100%;" v-model="edittemplet.problemIds" multiple >
						      <el-option v-for="el in worklist" :key="el.problemId" :value="el.problemId" :label="el.name"></el-option>
						    </el-select>							
						</el-col>
						<el-col :span="8" :offset="2">
							<el-radio-group v-model="workselect">
							    <el-radio-button label="1">只看自己</el-radio-button>
							    <el-radio-button label="2">共享作业</el-radio-button>
							    <el-radio-button label="3">内置作业</el-radio-button>
							</el-radio-group>							
						</el-col>
					</el-row>
				</el-form-item>		
				<el-form-item label="建议时长（小时）" label-width="80">
				    <el-input style="width:40%;" type="number" v-model="edittemplet.roughTime"></el-input>
				</el-form-item>			
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="editFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="editSubmit" :loading="editLoading">更新</el-button>
			</div>
		</el-dialog>	
		<!--设置界面-->
		<el-dialog  title="设置开课时间" :fullscreen="false" custom-class="dateformdate" width="30%"  v-model="paiFormVisible" :close-on-click-modal="false">
			<el-form :model="paiTime" status-icon class="demo-ruleForm"  :rules="paiTimerule" ref="paiTime" label-width="50px">		
				<el-form-item label="开课时间" label-width="80" prop="startTime" >
				    <el-date-picker 
				      v-model="paiTime.startTime"
				      type="datetime"
				      placeholder="选择日期时间">
				    </el-date-picker>						
				</el-form-item>	
				<el-form-item label="上课方式" label-width="80" prop="isOffline">
				    <el-select placeholder="请选择上课方式"  v-model="paiTime.isOffline">
				      <el-option  value="0" label="线上学习"></el-option>
				      <el-option  value="1" label="线下学习"></el-option>
				    </el-select>
				</el-form-item>		
				<el-form-item label="上课地点"  label-width="80" prop="location" v-if="paiTime.isOffline==1"> 
				    <el-input style="width:40%;" type="text" placeholder="填写上课地点"  v-model="paiTime.location"></el-input>
				</el-form-item>					
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="paiFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="paiFun">提交</el-button>
			</div>
		</el-dialog>		
		<!--设置界面-->
		<el-dialog  title="设置项目路演学时" :fullscreen="false" custom-class="dateformdate" width="30%"  v-model="RoadFormVisible" :close-on-click-modal="false">
			<el-form :model="paiTime" status-icon class="demo-ruleForm"  label-width="50px">			
				<el-form-item label="项目路演学时"  label-width="80"  > 
				    <el-input style="width:40%;" type="number"   v-model="roads[0].roughTime"></el-input>
				</el-form-item>					
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="RoadFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="changeRoadtime">提交</el-button>
			</div>
		</el-dialog>			
		<!--设置课程成员机制-->
		<el-dialog  title="设置课程成员" :fullscreen="false" custom-class="dateformdate" width="30%"  v-model="isFreeVisible" :close-on-click-modal="false">
			<el-form :model="addcourse" label-width="80px" :rules="addcourserule" ref="addcourse" >
			  <el-form-item label="自由申请" prop="isFree">
			    <el-radio-group v-model="addcourse.isFree">
			      <el-radio label="1">是</el-radio>
			      <el-radio label="0">否</el-radio>
			    </el-radio-group>
			  </el-form-item>		
			  <el-form-item label="上传文件" v-if="addcourse.isFree==0">
				<el-upload
				  class="upload-demo"
				  drag
				  action="cc"
				  :before-upload="beforeupload"
				  :file-list="fileList"
				  limit='1'
				  accept="xls/*">
				  <i class="el-icon-upload"></i>
				  <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
				  <div class="el-upload__tip" slot="tip">只能上传xlx文件</div>
				</el-upload>
		    	<a href="./static/img/用户模板.xls">
			    	<el-tag type="success">
					 	 点击下载文件模板
					</el-tag>
		    	</a>
			  </el-form-item>	
			</el-form>	
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="isFreeVisible = false">取消</el-button>
				<el-button type="primary" @click.native="addCOU" :loading="addLoading">创建课程</el-button>
		</div>
		</el-dialog>		
		<!--查看界面-->
		<el-dialog  title="查看课程章节" :fullscreen="false" custom-class="lookdialog" width="30%"  v-model="lookVisible" :close-on-click-modal="false">
			<template>
				<previews :tochild="looktemplet"  ref="dianss"></previews>
			</template>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="lookVisible = false">关闭</el-button>
			</div>
		</el-dialog>					
	</section>
</template>  

<script>
  import {templetlist,templetlistbuil,bussinesslist,templetone,videolist,worklist,drawlist,planlist,courseadd,coursenamerule,drawlistbuil,worklistbuil,videolistbuil,planlistbuil} from '../../api/api'
  import { quillEditor } from 'vue-quill-editor' //调用设置器
  import ComFunJS from '../../common/js/util'
  import preview from '../draw/previewstage.vue';
  export default {
    data() {  	
		let numberrule=(rule, value, callback)=>{
		  if (value < 0 || value > 100) {
		    callback(new Error('数值必须在 0 至 100之间'))
		  } else {
		    callback()
		  }							
		}    
		var courserule=(rules,value,callback)=>{
			let params={name:this.addcourse.name};
			coursenamerule(params).then((r)=>{
				if(!r){
					callback(new Error('课程名称重复'))
				}else{
					callback()
				}
			})
		}	
		let namelengthrule=(rule, value, callback)=>{
		  if (value.length > 15) {
		    callback(new Error('限制字数15字以内'))
		  } else {
		    callback()
		  }							
		}			
      return {
        active: 0,
        step:1,
        addFormVisible:false,
        addLoading:false,
        drawFormVisible:false,
        editFormVisible:false,
        editLoading:false,
        paiFormVisible:false,
        RoadFormVisible:false,
        isFreeVisible:false,
        lookVisible:false,
		planselect:"",
		videoselect:"",
		drawselect:"",
		workselect:"",
		planisShared:" ",				
		videoisShared:" ",	
		drawisShared:" ",	
		workisShared:" ",	
		planisSelf:"1",
		videoisSelf:"1",
		drawisSelf:"1",
		workisSelf:"1",   
		paiTime:{
			startTime:"",
			isOffline:true,
			location:""
		},
		paiTimerule:{
 			startTime:[
				{ required:true, message: '时间不能为空',},
			], 
 			isOffline:[
				{ required: true, message: '学习方式不能为空', trigger: 'blur' },
			], 
 			location:[
				{ required: true, message: '地址不能为空', trigger: 'blur' },
			], 			
		},
		quanzhong:{
			personWeight:"",
			teamWeight:"",
			completionWeight:"",
			performanceWeight:""
		},
		quanzhongrules:{
 			personWeight:[
				{ required: true, message: '不能为空', trigger: 'blur' },
				{required: true, validator:numberrule, trigger: 'blur'}
			],
 			teamWeight:[
				{ required: true, message: '不能为空', trigger: 'blur' },
				{required: true, validator:numberrule, trigger: 'blur'}
			], 
 			completionWeight:[
				{ required: true, message: '不能为空', trigger: 'blur' },
				{required: true, validator:numberrule, trigger: 'blur'}
			], 
 			performanceWeight:[
				{ required: true, message: '不能为空', trigger: 'blur' },
				{required: true, validator:numberrule, trigger: 'blur'}
			]			
		},		
        addcourse: {
          name: '',
          intro: '',
          teamCount:'',
          personCount:'',
          isFree:"1",
          startTime:"",
        },
        addcourserule:{
 			name:[
				{ required: true, message: '课程名称不能为空', trigger: 'blur' },
				{validator:courserule,trigger: 'blur'},
				{validator:namelengthrule,trigger: 'blur'},
			], 
			intro:[
				{ required: true, message: '课程简介不能为空', trigger: 'blur' }
			], 
			teamCount:[
				{ required: true, message: '上课组数不能为空', trigger: 'blur' }
			], 
			personCount:[
				{ required: true, message: '上课人数不能为空', trigger: 'blur' }
			], 	
			isFree:[
				{ required: true, message: '请选择学生申请方式', trigger: 'blur' }
			],	
			startTime:[
				{ required: true, message: '时间不能为空' }
			],	
        },
        edittemplet:{},
        templetbusinessModelId:'',     
        courseType:"",
        bussinessList:[],
        fileList:[],
		basis: [],
		casebox:[],
		derive:[],
		roads:[{name:'项目路演',roughTime:'2'}],
		Lists:[],
		testlist:[],
		testdrawlist:[],
		videolist:[],
		worklist:[],
		drawlist:[],				
		planlist:[],
		videolist2:[],
		worklist2:[],
		drawlist2:[],				
		planlist2:[],		
		stageJson:[{
			type:1,
			startTime:"",
			isOffline:0,
			drawingTypeIds:"",
			location:""
		},
		{
			type:2,
			startTime:"",
			isOffline:0,
			drawingTypeIds:"",
			location:"",
		},
		{
			type:3,
			startTime:"",
			drawingTypeIds:"",
			isOffline:0,
			location:"",
		},{
			type:4,
			startTime:"",
			isOffline:0,
			drawingTypeIds:"",
			location:"",
			roughTime:"2"
		}],
		unitJson:[],
		looktemplet:{
			
		},
		edittempletrule: {
			roughTime:[
				{ required: true, message: '建议时长不能为空', trigger: 'blur' }
			],
			isOffline:[
				{ required: true, message: '上课时间方式不能为空', trigger: 'blur' }
			],
			location:[
				{ required: true, message: '上课时间地点不能为空', trigger: 'blur' }
			]	
		},		
		drawlit:[{name:'消费者体验流程图',type:'1',roughTime:'1'},{name:'典型人物',type:'2',roughTime:'1'},{name:'服务蓝图',type:'3',roughTime:'1'},{name:'商业模式画布',type:'4',roughTime:'1'},{name:'电梯演讲',type:'5',roughTime:'1'},{name:'洞察分析',type:'6',roughTime:'1'},{name:'思维导图',type:'7',roughTime:'1'}],
		templet:{
			total:'',
			page:'1',
			pagesize:'5',	
			isShared:' ',
			isSelf:'1',
			courseStage:'',
			key:"",
			templettype:'1',
		},
		editIndex:"", 
		coursestepindex:"",
		param:"",
      }
    },
    watch:{
    	'addcourse.teamCount':function(){
    		this.addcourse.personCount=JSON.stringify(parseInt(this.addcourse.teamCount)*6)
    	},
     	'addcourse.personCount':function(){
    		this.addcourse.teamCount=JSON.stringify(parseInt(this.addcourse.personCount)/6)
    	},   	
    	'templet.templettype':function(){
    		if(this.templet.templettype=='1'){
    			this.templet.isSelf=1;
    			this.templet.isShared=''
    		}
     		if(this.templet.templettype=='2'){
    			this.templet.isSelf=2;
    			this.templet.isShared=1
    		}   
    		if(this.templet.templettype=='3'){
    			this.templet.isSelf=3;
    			this.templet.isShared=''   			
				this.planselect=this.templet.templettype;
				this.videoselect=this.templet.templettype;
				this.drawselect=this.templet.templettype;
				this.workselect=this.templet.templettype;	    			
    		}
 			this.getList();
    	},	    	
		'planselect':function(){
			if(this.planselect==1){
				this.planisShared='';
				this.planisSelf=1;
			}
			if(this.planselect==2){
				this.planisShared=1;
				this.planisSelf=2;
			}
			if(this.planselect==3){
				this.planisShared='';
				this.planisSelf=3;					
			}	
			this.getplanList();							

		},
		'videoselect':function(){
			if(this.videoselect==1){
				this.videoisShared='';
				this.videoisSelf=1;
			}
			if(this.videoselect==2){
				this.videoisShared=1;
				this.videoisSelf=2;
			}
			if(this.videoselect==3){
				this.videoisShared='';
				this.videoisSelf=3;					
			}	
			this.getvideoList();							

		},
		'workselect':function(){
			if(this.workselect==1){
				this.workisSelf=1;
				this.workisShared='';					
			}
			if(this.workselect==2){
				this.workisSelf=2;
				this.workisShared=1;					
			}
			if(this.workselect==3){
				this.workisSelf=3;
				this.workisShared='';							
			}	
			this.getworkList();	
		},
		'drawselect':function(){
			if(this.drawselect==1){
				this.drawisSelf=1;
				this.drawisShared='';						
			}
			if(this.drawselect==2){
				this.drawisShared=1;
				this.drawisSelf=2;	
			}
			if(this.drawselect==3){
				this.drawisShared='';
				this.drawisSelf=3;						
			}	
			this.getdrawList();							
		}			    	
    },
    computed: {
      editor() {
        return this.$refs.myQuillEditor.quill
      }
    },    
    components: {
      quillEditor,
      'previews':preview
    }, 	
    methods: {
 			Lookone:function(row){		
 				var _this = this;
				var params=row.templetId+"?deep=2";
				if(row.videos==null){
					templetone(params).then((res)=>{
						if(!res.error){
							_this.looktemplet = Object.assign({}, res);
						}
					})	 					
				}else{
					_this.looktemplet = Object.assign({}, row);
				}				
				_this.lookVisible=true;			
			},	   	
    		OpenIsfree:function(){
    			this.isFreeVisible=true
    		},
		    skip(link,id,type){
		        this.$router.push(
		        	{
		        		path:link,
		        		query:{
		        			id:id,
		        			type:type
		        		}
		        	}
		        )
		    },	    	
            beforeupload(file) {
                //创建临时的路径来展示图片
                var windowURL = window.URL || window.webkitURL;
                var planname=file.name;
                let oneplan={name:planname,url:''};
                this.fileList=[];
                this.fileList.push(oneplan);
                //重新写一个表单上传的方法
                this.param = new FormData();
                this.param.append('file', file, file.name);
                return false;
            },	    	
    		paiIndex:function(index){
    			this.coursestepindex=index;
    			this.paiTime.startTime=this.stageJson[index].startTime;
    			this.paiTime.isOffline=JSON.stringify(this.stageJson[index].isOffline);
    			this.paiTime.location=this.stageJson[index].location;
    			this.paiFormVisible=true;
    		},
    		paiFun:function(){
    			if(this.paiTime.startTime==''){
 					this.$message({
						message: '时间不能为空',
						type: 'error'
					});      				
					return
    			}
				this.$refs.paiTime.validate((valide)=>{
					if(valide){
		    			this.stageJson[this.coursestepindex].startTime=ComFunJS.getNowDate('yyyy-MM-dd HH:mm',this.paiTime.startTime);
		    			this.stageJson[this.coursestepindex].location=this.paiTime.location;
		    			this.stageJson[this.coursestepindex].isOffline=JSON.parse(this.paiTime.isOffline);
		    			this.paiTime.startTime="";
		    			this.paiTime.location="";
		    			this.paiTime.isOffline="";
		    			this.paiFormVisible=false;								
					}
				})
    		},
    	    stepnext:function(){
    	    	if(this.step==1){
    	    		if(this.addcourse.startTime==''){
						this.$message({
							message: '请选择开课时间',
							type: 'error'
						});      	
						return
    	    		}
    	    		if(this.addcourse.startTime<new Date()){
 						this.$message({
							message: '开课时间不能小于当前时间',
							type: 'error'
						});      	
						return   	    			
    	    		}
	    	    	this.$refs.addcourse.validate((valide)=>{
	    	    		if(valide){
							this.step=2
	    	    		}
	    	    	})
	    	    	this.addcourse.startTime=ComFunJS.getNowDate('yyyy-MM-dd HH:mm',this.addcourse.startTime);
	    	    	return

    	    	}   
    	    	if(this.step==2){
    	    		if(this.basis.length==0||this.casebox.length==0||this.derive.length==0){
						this.$message({
							message: '课程板块不能有空余',
							type: 'error'
						});   	    			
						return
    	    		}else{
    	    			this.step=3
    	    		}
    	    		return
    	    	}
    	    	if(this.step==3){
    	    		var _this=this;
    	    		var pass=0;
    	    		$.each(_this.stageJson, function(e,value) {
    	    			if(pass==1){
    	    				_this.$message({
								message: '还要课程板块未排课',
								type: 'error'
							});   	    				
    	    				return
    	    			}else{
	    	    			if(value.startTime==''){
								pass=1;
								return
	    	    			}    				
    	    			}
    	    		});
					if(pass==0){
						_this.step=4;  
					}
    	    		return;
    	    	}
    	    	if(this.step==4){
    	    		this.OpenIsfree()
    	    		return
    	    	}    	    	
    	    },
    	    stepprive:function(){
    	    	if(this.step==1){
    	    		return
    	    	}else{
    	    		this.step--;	
    	    	}
    	    },
    		updatelist:function(){
    			this.basis=this.basis;
    		},
    		changeRoadtime:function(){
    			this.stageJson[3].roughTime=this.roads[0].roughTime;
    			this.RoadFormVisible=false;
    		},
			getvideoList: function (type) {
				var courseStage=this.edittemplet.courseStage;
				if(courseStage==1){
					var businessModelId=null
				}else{
					var businessModelId=this.edittemplet.businessModelId
				}
				let params={pageSize:0,sign:this.videoisSelf,isShared:this.videoisShared,courseStage:courseStage};
				videolist(params).then((res) => {
					$.each(res.list, function(e,value) {
						value.videoId=JSON.stringify(value.videoId)
					});
					this.videolist = res.list;
				});	
			},
			getworkList: function (type) {
					var courseStage=this.edittemplet.courseStage;
					if(courseStage==1){
						var businessModelId=null
					}else{
						var businessModelId=this.edittemplet.businessModelId
					}
			
				let params={pageSize:0,sign:this.workisSelf,isShared:this.workisShared,courseStage:courseStage};
				worklist(params).then((res) => {
					$.each(res.list, function(e,value) {
						value.problemId=JSON.stringify(value.problemId)						
					});						
					this.worklist = res.list;
				});
			},		
			getdrawList: function (type) {
					var courseStage=this.edittemplet.courseStage;
					if(courseStage==1){
						var businessModelId=null
					}else{
						var businessModelId=this.edittemplet.businessModelId
					}
				let params={pageSize:0,sign:this.drawisSelf,isShared:this.drawisShared,courseStage:courseStage};
				drawlist(params).then((res) => {
					$.each(res.list, function(e,value) {
						value.drawingId=JSON.stringify(value.drawingId)						
					});						
					this.drawlist = res.list;
				});	
			},	
			getplanList: function (type) {
				var courseStage=this.edittemplet.courseStage;
				if(courseStage==1){
					var businessModelId=null
				}else{
					var businessModelId=this.edittemplet.businessModelId
				}			
				let params={pageSize:0,sign:this.planisSelf,isShared:this.planisShared,courseStage:courseStage};
				planlist(params).then((res) => {
					$.each(res.list, function(e,value) {
						value.planId=JSON.stringify(value.planId)						
					});							
					this.planlist = res.list;
				});	
			},	   
			getAllList:function(courseStage,businessModelId){
				var _this=this;
				_this.worklist=[];
				_this.drawlist=[];
				_this.videolist=[];
				_this.planlist=[];
				_this.worklist2=[];
				_this.drawlist2=[];
				_this.videolist2=[];
				_this.planlist2=[];				
				let selfparams={pageSize:0,sign:4,courseStage:courseStage};
				worklist(selfparams).then((res) => {
					$.each(res.list, function(e,value) {
						value.problemId=JSON.stringify(value.problemId)	
						_this.worklist.push(value);
						_this.worklist2.push(value)
					});
				});					
				drawlist(selfparams).then((res) => {
					$.each(res.list, function(e,value) {
						value.drawingId=JSON.stringify(value.drawingId)	
						_this.drawlist.push(value);
						_this.drawlist2.push(value)
					});
				});			
				videolist(selfparams).then((res) => {
					$.each(res.list, function(e,value) {
						value.videoId=JSON.stringify(value.videoId)	
						_this.videolist.push(value);
						_this.videolist2.push(value)
					});
				});		
				planlist(selfparams).then((res) => {
					$.each(res.list, function(e,value) {
						value.planId=JSON.stringify(value.planId)	
						_this.planlist.push(value);
						_this.planlist2.push(value)
					});
				});		
			},		
			getone:function(row,index,type){
				this.courseType=type;			
				if(type=='basis'){
					row=this.basis[index];
				}else{
					row=this.casebox[index];
					row.businessModelId=null;			
				}			
				var _this = this;
				_this.getAllList(row.courseStage,row.businessModelId)
				this.editIndex=index;				
				_this.edittemplet={};			
				if(!row.type){
					row.type="";
				}					
				if(row.drawingIds){
					if(!Array.isArray(row.drawingIds)){
						row.drawingIds=row.drawingIds.split(',')
					}		
				}else{
					row.drawingIds=[]
				}
				if(row.problemIds){
					if(!Array.isArray(row.problemIds)){
						row.problemIds=row.problemIds.split(',')
					}			
				}else{
					row.problemIds=[]
				}				
				if(row.planIds){
					if(!Array.isArray(row.planIds)){
						row.planIds=row.planIds.split(',')
					}			
				}else{
					row.planIds=[]
				}
				if(row.videoIds){
					if(!Array.isArray(row.videoIds)){
						row.videoIds=row.videoIds.split(',')
					}			
				}else{
					row.videoIds=[]
				}							
				_this.edittemplet = Object.assign({}, row);
				_this.editFormVisible=true;
			},    
			//新增
			addCOU: function () {
				var _this=this;
				if(this.fileList.length==0&&this.addcourse.isFree==0){
					this.$message({
						message: '请上传相关文件',
						type: 'error'
					});   					
					return false;
				}				
				var addnumber=parseInt(_this.quanzhong.personWeight)+parseInt(_this.quanzhong.teamWeight)+parseInt(_this.quanzhong.completionWeight)+parseInt(_this.quanzhong.performanceWeight);
				if(addnumber!=100){
					_this.$message({
						message: '四个课程权重和必须为100%',
						type: 'error'
					});		
					return
				}
				if(_this.addcourse.isFree==1){
					_this.param=new URLSearchParams()
				}			
				var drawingIds=[];
				var templetIds=[];
				_this.unitJson=[]
				$.each(_this.basis, function(e,value) {
					_this.unitJson.push(value);
					
				});
				$.each(_this.casebox, function(e,value) {
					_this.unitJson.push(value);
				});			
				$.each(_this.derive, function(e,value) {
					drawingIds.push(value.type);
				});		
				$.each(_this.unitJson,function(e,value){
					if(value.videoIds==null){
						value.videoIds="";
					}else{
						value.videoIds=value.videoIds
					}
					if(value.planIds==null){
						value.planIds="";
					}else{
						value.planIds=value.planIds;
					}					
					if(value.problemIds==null){
						value.problemIds="";
					}else{
						value.problemIds=value.problemIds;
					}
					if(value.drawingIds==null){
						value.drawingIds="";
					}else{
						value.drawingIds=value.drawingIds;
					}	
					if(Array.isArray(value.videoIds)){
						value.videoIds=value.videoIds.join(',')
					}
					if(Array.isArray(value.planIds)){
						value.planIds=value.planIds.join(',')
					}
					if(Array.isArray(value.problemIds)){
						value.problemIds=value.problemIds.join(',')
					}
					if(Array.isArray(value.drawingIds)){
						value.drawingIds=value.drawingIds.join(',')
					}					
					delete value.businessModelName;
					delete value.createTime;
					delete value.intro;
					delete value.isShared;
					delete value.orgId;
					delete value.orgName;
					delete value.realName;
					delete value.updateTime;
					delete value.userId;		
					delete value.referenceCount;
				
				})
				this.$refs.quanzhong.validate((valid)=>{
					if(valid){
						this.stageJson[2].drawingTypeIds=drawingIds.toString();
						this.param.append('name',this.addcourse.name);
						this.param.append('intro',this.addcourse.intro);
						this.param.append('teamCount',this.addcourse.teamCount);
						this.param.append('personCount',this.addcourse.personCount);
						this.param.append('isFree',this.addcourse.isFree);
						this.param.append('personWeight',this.quanzhong.personWeight);
						this.param.append('teamWeight',this.quanzhong.teamWeight);
						this.param.append('completionWeight',this.quanzhong.completionWeight);
						this.param.append('performanceWeight',this.quanzhong.performanceWeight);
						this.param.append('startTime',this.addcourse.startTime);
						this.param.append('stageJson',JSON.stringify(this.stageJson));
						this.param.append('unitJson',JSON.stringify(this.unitJson) );
						this.$confirm('确认提交吗？', '提示', {
					        confirmButtonText: '确定',
					        cancelButtonText: '取消',					
							type: 'warning'							
						}).then(() => {
							courseadd(this.param).then((r) => {
								if(!r.error){
									this.addLoading = false;
									this.$message({
										message: '课程创建成功',
										type: 'success'
									});
									this.skip('/schedulelist')
								}else{
									this.$message({
										message:r.message,
										type: 'error'
									});										
								}
							})
						}).catch(() => {
							this.addLoading = false;					
						});						
					}
				})
			},			
			//设置
			editSubmit: function () {
				var _this=this;
				_this.$refs.edittemplet.validate((valid)=>{
					if(valid){
						_this.edittemplet.videos=[];
						_this.edittemplet.problems=[];
						_this.edittemplet.drawings=[];
						_this.edittemplet.plans=[];		
						$.each(_this.edittemplet.videoIds,function(e,value){
							$.each(_this.videolist2,function(i,result){
								if(value==result.videoId){
									_this.edittemplet.videos.push(result)
								}
							})
						})
						$.each(_this.edittemplet.problemIds,function(e,value){
							$.each(_this.worklist2,function(i,result){
								if(value==result.problemId){
									_this.edittemplet.problems.push(result)
								}
							})
						})		
						$.each(_this.edittemplet.drawingIds,function(e,value){
							$.each(_this.drawlist2,function(i,result){
								if(value==result.drawingId){
									_this.edittemplet.drawings.push(result)
								}
							})
						})	
						$.each(_this.edittemplet.planIds,function(e,value){
							$.each(_this.planlist2,function(i,result){
								if(value==result.planId){
									_this.edittemplet.plans.push(result)
								}
							})
						})							
						_this.edittemplet.videoIds=_this.edittemplet.videoIds.join(',');
						_this.edittemplet.problemIds=_this.edittemplet.problemIds.join(',');
						_this.edittemplet.drawingIds=_this.edittemplet.drawingIds.join(',');
						_this.edittemplet.planIds=_this.edittemplet.planIds.join(',');
						if(_this.courseType=='basis'){
							_this.edittemplet.type=1;
							_this.basis[_this.editIndex]=_this.edittemplet;	
							_this.swapItems(_this.basis,_this.editIndex,_this.editIndex);
						}else{
							_this.edittemplet.type=2;
							_this.casebox[_this.editIndex]=_this.edittemplet;	
							_this.swapItems(_this.casebox,_this.editIndex,_this.editIndex);			
						}
						_this.editFormVisible=false;		
						_this.$message({
							type: 'success',
							message: '更新成功'		
						});	
					}
				})

			},					
    	addraw:function(){
    		var _this=this;
			if(_this.derive.length>0){
				var pass=0
				$.each(_this.testdrawlist, function(i,result) {
					$.each(_this.derive, function(e,value) {
						if(result.name!=value.name){		
							pass=1;
						}else{
							pass=0;
							return false;
						}
					});
					if(pass==1){
						_this.derive.push(result);							
					}					
				});
			}else{
				_this.derive=_this.testdrawlist;
			}   	
			this.$refs.multipleTable.clearSelection();
			this.drawFormVisible=false;
   		 },
	     toggleSelection(rows) {
	        if (rows) {
	          rows.forEach(row => {
	            this.$refs.multipleTable.toggleRowSelection(row);
	          });
	        } else {
	          this.$refs.testdrawlist.clearSelection();
	        }
	      },  		 
	    addtemplebox:function(value,type){
			this.templet={
				total:'',
				page:'1',
				pagesize:'10',	
				isShared:' ',
				isSelf:'1',
				templettype:"1",
				courseStage:value,
				key:""
			};
			this.courseType=type;
			this.getList();
			this.getbussinesslist();
			this.addFormVisible=true;

		},
		drawSelectionChange:function(value){
			this.testdrawlist=value;
		},		
		handleSelectionChange:function(value){
			this.testlist=value;
		},
		swapItems:function(arr, index1, index2) {
	        arr[index1] = arr.splice(index2, 1, arr[index1])[0];
	        return arr;
	    }, 		
		upRecord:function(arr, $index) {
	        if($index == 0) {
	            return;
	        }
	        this.swapItems(arr, $index, $index - 1);
		},
		downRecord:function(arr, $index) {
	        if($index == arr.length -1) {
	            return;
	        }
	        this.swapItems(arr, $index, $index + 1);
    	},	
    	deletelist:function(type,$index){
    		var _this= this;
			_this.$confirm('确认删除该记录吗?', '提示', {
		        confirmButtonText: '确定',
		        cancelButtonText: '取消',					
				type: 'warning',
			}).then(() => {
				if(type=='basis'){
					_this.basis.splice($index,1)
				};
				if(type=='case'){
					_this.casebox.splice($index,1)
				}
				if(type=='draw'){
					_this.derive.splice($index,1)
				}					
			})    		
    	},
		addList:function(type){
			var _this=this;
			if(_this.testlist.length==0){
				_this.$message({
					type: 'error',
					message: '请选择小节'		
				});	
				return;
			}
			if(_this.courseType=='basis'){
				if(_this.basis.length>0){
					var pass=0
					$.each(_this.testlist, function(i,result) {
						result.type=1;
						$.each(_this.basis, function(e,value) {
							if(result.templetId!=value.templetId){		
								pass=1;
							}else{
								pass=0;
								return false;
							}
						});
						if(pass==1){
							_this.basis.push(result);							
						}					
					});
				}else{
					$.each(_this.testlist, function(i,result) {
						result.type=1;				
					});					
					_this.basis=_this.testlist;
				}
			}
			if(_this.courseType=='case'){
				if(_this.casebox.length>0){
					var pass=0
					$.each(_this.testlist, function(i,result) {
						result.type=2;
						$.each(_this.casebox, function(e,value) {
							if(result.templetId!=value.templetId){		
								pass=1;
							}else{
								pass=0;
								return false;
							}
						});
						if(pass==1){
							_this.casebox.push(result);							
						}					
					});
				}else{
					$.each(_this.testlist, function(i,result) {
						result.type=2;				
					});						
					_this.casebox=_this.testlist;
				}
			}						
			_this.$message({
				type: 'success',
				message: '添加成功'		
			});	
			_this.testlist=[];
			_this.addFormVisible = false;
		},
		handleCurrentChange(val) {
			this.templet.page = val;
			this.getList();
		},			
		getbussinesslist:function(){
			bussinesslist().then((res)=>{

				this.bussinessList=res;
			})
		},			
		getList: function () {
			this.loading = true;
			//NProgress.start();
			var courseStage=this.templet.courseStage;
			if(courseStage==1){
				var businessModelId=null;
			}else{
				var businessModelId=this.templetbusinessModelId;
			}
			let params={pageNum:this.templet.page,pageSize:5,courseStage:this.templet.courseStage,key:this.templet.key,isShared:this.templet.isShared,sign:this.templet.isSelf,businessModelId:this.templetbusinessModelId};
			templetlist(params).then((res) => {
				this.templet.total=res.total;		
				this.Lists = res.list;
				this.loading = false;
			});	
		},		
   },
	mounted() {

	}    
  }
</script>


<style>
	.box-content{
		margin-bottom: 10px;
	}
	.text-item{
		padding: 10px 15px;
	}
	.text-box{
		margin-bottom: 5px;
	}
	.card-margin{
		margin-bottom: 20px;
	}
	.dateformdate{
		width: 30%;
	}
	.lookdialog{
	width: 100%;
	top: 0!important;
}
</style>